package com.xinxin.leetcode.common;

import java.lang.reflect.Array;

/**
 * @author ：史鑫鑫
 * @date ：Created in 2019/4/25 3:47
 */
public class ListUtil {
    private ListUtil() {
    }

    public static ListNode createList(int[] array) {
        if (array == null || array.length == 0) {
            return null;
        }
        ListNode dummyHead = new ListNode(-1);
        ListNode cur = dummyHead;
        for (int i = 0; i < array.length; i++) {
            cur.next = new ListNode(array[i]);
            cur = cur.next;
        }
        return dummyHead.next;
    }

    public static void printList(ListNode head) {
        while (head != null) {
            System.out.print(head.val+" -> ");
            head = head.next;
        }
        System.out.println("NULL");
    }
}
